package cloud.maque.module.system.controller;

import cloud.maque.common.core.response.R;
import cloud.maque.module.system.entity.SysMenu;
import cloud.maque.module.system.extend.MenuExtendService;
import cloud.maque.module.system.model.MenuDto;
import cloud.maque.module.system.service.MenuService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 菜单
 */
@Tag(name = "菜单接口")
@RestController
@RequestMapping(value = "/menu")
public class MenuController {


    @Autowired
    MenuService menuService;

    @Autowired
    MenuExtendService extendService;

    @Operation(summary = "菜单列表")
    @PostMapping("/list")
    public R<List<MenuDto>> List(@RequestBody SysMenu pageReq) {
        return R.ok("OK", extendService.GetMenuList(pageReq));
    }

    @Operation(summary = "菜单保存")
    @PostMapping("/save")
    public R<SysMenu> Save(@RequestBody SysMenu data) {

        return R.ok("OK", menuService.SaveMenu(data));
    }


    @Operation(summary = "菜单删除")
    @DeleteMapping("/delete/{id}")
    public R<Boolean> Delete(@PathVariable("id") String id) {
        return R.ok("OK", menuService.DeleteMenu(id));
    }
}
